package diaguml;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import pilebis.DrawEnvironnement;


public class Gui {
	
	private static final long serialVersionUID = 1L;
	private static JFrame jframe;
	private DrawDiagramme paint;

	
	public Gui() throws ParserConfigurationException, SAXException, IOException{
		super();
		this.jframe = new JFrame("Construction ");
		
		jframe.setSize(1000, 1000);
		jframe.setLocationRelativeTo(null);
		Container content = jframe.getContentPane();
	    content.setBackground(Color.WHITE);
	    content.setLayout(new BorderLayout()); 
	    JFileChooser fChooser = new JFileChooser("./xml");
		FileNameExtensionFilter filter = new FileNameExtensionFilter("Fichiers XML", "xml");
		fChooser.setFileFilter(filter);
		fChooser.showOpenDialog(null);
		System.out.println(fChooser.getSelectedFile().getPath());
		
		ParseurXML parseur = new ParseurXML(fChooser.getSelectedFile().getPath());
		List<Etiquette> res = new ArrayList<Etiquette>();
		res = parseur.getEtiquettes();
		
		List<Liaison> res2 = new ArrayList<Liaison>();
		res2 = parseur.getLiaisons();
	    paint = new DrawDiagramme(res,res2);
		//Image image = jframe.createImage(50,50);
		//Graphics gc = image.getGraphics();
		//gc.setColor(Color.green);
		//gc.fillOval(0,0,40,20);
	    content.add(paint);
		jframe.pack();
		jframe.setVisible(true);
		
		
	}
	
	
	
	public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException{
		
		new Gui();
		
	}
}


